<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <div>Arr</div>
        {{arr}} <br>
        <button @click="changArr">点击更改Arr</button>
        <div>User</div>
        {{user}} <br>
        <button @click="changUser">点击更改User</button>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                arr: [1, 2, 3],
                user: { a: 1 },
            },
            methods: {
                changArr() {
                    // this.arr[1] = 888;
                    console.log(this.arr);
                    // set  要修改的数组,修改的索引下标,修改的值
                    Vue.set(this.arr, 1, 888)
                },
                changUser() {
                    // this.user.b = '李四';
                    // this.user.a = '芜湖'
                    console.log(this.user);
                    // $set 要修改的数组,修改的属性,修改的值
                    this.$set(this.user, 'b', '张三')
                }
            }
        })
    </script>
</body>

</html>